﻿namespace HuwmanCode.Samples.WindowsService

open System
open HuwmanCode.ServiceProcess
open HuwmanCode.Diagnostics.Logging

module Program =
    //The entry point for the application, the file that houses this code needs to be the last file
    [<EntryPoint>]
    let main args =
        Logger.CreateDefaultLogger((fun _ -> seq [new ConsoleEventWriter();new WindowsEventWriter()]), new TraceEventWriter())
        let recover (serviceName:string) (failCount:int) =
            System.Diagnostics.Debugger.Launch() |> ignore
            System.Diagnostics.Debug.WriteLine(sprintf "%s has failed %i time(s)!" serviceName failCount)

        WindowsServiceBase.Run(recover) |> ignore //Give control to the framework

        0 //return 0, the application ran without error
